<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
<ui:composition template="../templates/layout.xhtml">
  <ui:define name="content">
    <h:form prependId="false" id="growlForm">
      <p:growl id="growl" showDetail="false" />
    </h:form>
    <h:form prependId="false" id="dataForm">
      <p:panel id="data" toggleable="true" toggleSpeed="250">
        <f:facet name="header">
          <h:outputText value="#{cityBean.name}" />
        </f:facet>
        <h:outputFormat id="noRecordsFound" value="#{messages.label_no_records_found}" rendered="#{!cityBean.dataVisible}">
          <f:param value="Citys" />
        </h:outputFormat>
        <p:dataTable id="list" value="#{cityBean.allCitys}" var="city" rendered="#{cityBean.dataVisible}" resizableColumns="false" paginator="true" paginatorTemplate=" {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,25,50" rows="10">
          <p:columns value="#{cityBean.columns}" var="column" columnIndexVar="colIndex">
            <f:facet name="header">
              <h:outputText value="#{applicationBean.getColumnName(column)}" />
            </f:facet>
            <h:outputText value="#{city[column]}" />
          </p:columns>
          <p:column styleClass="action-column">
            <f:facet name="header">
              <h:outputText value="Actions" />
            </f:facet>
            <p:commandButton id="viewButton" icon="ui-icon-zoomin" update=":viewForm:viewPanelGrid" oncomplete="viewDialog.show()" title="#{messages.label_view}">
              <f:setPropertyActionListener value="#{city}" target="#{cityBean.city}" />
            </p:commandButton>
            <p:tooltip for="viewButton" value="#{messages.label_view}" showEffect="fade" hideEffect="fade" />
            <p:commandButton id="editButton" icon="ui-icon-pencil" update=":editForm:editPanelGrid" action="#{cityBean.onEdit}" oncomplete="editDialog.show()" title="#{messages.label_edit}">
              <f:setPropertyActionListener value="#{city}" target="#{cityBean.city}" />
            </p:commandButton>
            <p:tooltip for="editButton" value="#{messages.label_edit}" showEffect="fade" hideEffect="fade" />
            <p:commandButton id="deleteButton" icon="ui-icon-trash" oncomplete="deleteDialog.show()" title="#{messages.label_delete}">
              <f:setPropertyActionListener value="#{city}" target="#{cityBean.city}" />
            </p:commandButton>
            <p:tooltip for="deleteButton" value="#{messages.label_delete}" showEffect="fade" hideEffect="fade" />
          </p:column>
        </p:dataTable>
      </p:panel>
    </h:form>
    <p:dialog id="createDialog" header="#{messages.label_create} City" modal="true" widgetVar="createDialog" dynamic="true" visible="#{cityBean.createDialogVisible}" resizable="true" maximizable="true" showEffect="fade" hideEffect="explode">
      <p:ajax event="close" update=":dataForm:data" listener="#{cityBean.handleDialogClose}" />
      <p:outputPanel id="createPanel">
        <h:form id="createForm" enctype="multipart/form-data">
          <h:panelGrid id="createPanelGrid" columns="3" binding="#{cityBean.createPanelGrid}" styleClass="dialog" columnClasses="col1,col2,col3" />
          <p:commandButton id="createSaveButton" value="#{messages.label_save}" action="#{cityBean.persist}" update="createPanelGrid :growlForm:growl" />
          <p:commandButton id="createCloseButton" value="#{messages.label_close}" onclick="createDialog.hide()" type="button" />
        </h:form>
      </p:outputPanel>
    </p:dialog>
    <p:dialog id="editDialog" header="#{messages.label_edit} City" modal="true" widgetVar="editDialog" dynamic="true" resizable="true" maximizable="true" showEffect="fade" hideEffect="explode">
      <p:ajax event="close" update=":dataForm:data" listener="#{cityBean.handleDialogClose}" />
      <p:outputPanel id="editPanel">
        <h:form id="editForm" enctype="multipart/form-data">
          <h:panelGrid id="editPanelGrid" columns="3" binding="#{cityBean.editPanelGrid}" styleClass="dialog" columnClasses="col1,col2,col3" />
          <p:commandButton id="editSaveButton" value="#{messages.label_save}" action="#{cityBean.persist}" update="editPanelGrid :growlForm:growl" />
          <p:commandButton id="editCloseButton" value="#{messages.label_close}" onclick="editDialog.hide()" type="button" />
        </h:form>
      </p:outputPanel>
    </p:dialog>
    <p:dialog id="viewDialog" header="#{messages.label_view} City" modal="true" widgetVar="viewDialog" dynamic="true" resizable="true" maximizable="true" showEffect="fade" hideEffect="explode">
      <p:outputPanel id="viewPanel">
        <h:form id="viewForm" enctype="multipart/form-data">
          <h:panelGrid id="viewPanelGrid" columns="2" binding="#{cityBean.viewPanelGrid}" styleClass="dialog" columnClasses="col1,col2" />
          <p:commandButton id="viewCloseButton" value="#{messages.label_close}" onclick="viewDialog.hide()" type="button" />
        </h:form>
      </p:outputPanel>
    </p:dialog>
    <p:confirmDialog id="deleteDialog" widgetVar="deleteDialog" message="#{messages.label_delete_record}" showEffect="fade" hideEffect="explode" header="#{messages.label_confirm_deletion}" severity="alarm">
      <p:outputPanel id="deletePanel">
        <h:form id="deleteForm">
          <p:commandButton id="deleteYesButton" value="#{messages.label_yes}" action="#{cityBean.delete}" update=":dataForm:data :growlForm:growl" oncomplete="deleteDialog.hide()" />
          <p:commandButton id="deleteNoButton" value="#{messages.label_no}" onclick="deleteDialog.hide()" type="button" />
        </h:form>
      </p:outputPanel>
    </p:confirmDialog>
  </ui:define>
  
</ui:composition>
</html>